import { createApp } from 'vue';
import { createPinia } from 'pinia';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import App from './App.vue';
import router from './router';
import 'element-plus/dist/index.css';
import './assets/css/icon.css';
import directive from "@/directive"
import svgIcon from '@/icons'
// 分页组件
import Pagination from '@/components/Pagination/index.vue'
// 注册指令
import plugins from './plugins' // plugins

import { parseTime, resetForm, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi.js'
// 自定义树选择组件
import TreeSelect from '@/components/TreeSelect/index.vue'

const app = createApp(App);
app.component('Pagination', Pagination)
app.component('TreeSelect', TreeSelect)

directive(app)
app.use(createPinia());
app.use(router);
app.use(svgIcon)
app.use(plugins)

app.config.errorHandler = (err, vm, info) => {
    // 在此处处理错误
    console.log("err:",err)
  }
  // 全局方法挂载
app.config.globalProperties.parseTime = parseTime
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.handleTree = handleTree
app.config.globalProperties.addDateRange = addDateRange
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels
// 注册elementplus图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.mount('#app');
